<template>
  <div>
    <el-form :model="employee" ref="employeeForm" label-width="100px">
      <el-form-item label="姓名" prop="name">
        <el-input v-model="employee.name"></el-input>
      </el-form-item>
      <el-form-item label="用户名" prop="username">
        <el-input v-model="employee.username"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input type="password" v-model="employee.password"></el-input>
      </el-form-item>
      <el-form-item label="手机号" prop="phone">
        <el-input v-model="employee.phone"></el-input>
      </el-form-item>
      <el-form-item label="性别" prop="gender">
        <el-radio-group v-model="employee.gender">
          <el-radio label="male">男</el-radio>
          <el-radio label="female">女</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item label="身份证号" prop="idCard">
        <el-input v-model="employee.idCard"></el-input>
      </el-form-item>
      <el-form-item label="员工类型" prop="type">
        <el-radio-group v-model="employee.type">
          <el-radio label="fulltime">全职</el-radio>
          <el-radio label="parttime">兼职</el-radio>
          <el-radio label="internship">实习</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      employee: {
        name: "",
        username: "",
        password: "",
        phone: "",
        gender: "",
        idCard: "",
        type: "",
      },
    };
  },
  methods: {
    submitForm() {
      this.$refs.employeeForm.validate((valid) => {
        if (valid) {
          // 此处编写表单提交逻辑
          console.log(this.employee);
        } else {
          console.log("表单验证失败");
          return false;
        }
      });
    },
  },
};
</script>